package zhoug.player.qly;

import com.cmcc.qlyopensdk.vo.response.CameraSettingInfo;
import com.cmcc.qlyopensdk.vo.response.TimeLineSectionBean;
import zhoug.player.core.CameraAbility;
import zhoug.player.core.CameraSetting;
import zhoug.player.core.RecordSegment;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Author: zhoug
 * @Date: 2024-12-09
 * @Description:
 */
public class QlyDataParser {

    /**
     * 千里眼摄像头设置转换成通用设置信息
     *
     * @param source
     * @return
     */
    public static CameraSetting parse(CameraSettingInfo source) {
        CameraSetting result = null;
        if (source != null) {
            result = new CameraSetting();
            result.setAppId(source.getAppId());
            result.setDeviceId(source.getDeviceId());
            result.setDeviceName(source.getDeviceName());
            result.setDeviceStatus(source.getDeviceStatus());
            result.setQualityVideo(source.getHdVideo());
        }
        return result;
    }

    /**
     * 千里眼回放片段转换成通用回放片段
     * @param source
     * @return
     */
    public static List<RecordSegment> parseTimelineSectionResponse(List<TimeLineSectionBean> source) {
        List<RecordSegment> segments = new ArrayList<>();
        if (source != null && !source.isEmpty()) {
            for (TimeLineSectionBean item : source) {
                RecordSegment recordSegment = new RecordSegment(item.getStartTime(), item.getEndTime());
                recordSegment.setThumbnailUrl(item.getThumbnailUrl());
                segments.add(recordSegment);
            }
            Collections.sort(segments);
        }
        return segments;
    }


    /**
     * 千里眼摄像头设置转换成通用设置信息
     *
     * @param source
     * @return
     */
    public static CameraAbility parse(com.cmcc.qlyopensdk.vo.response.CameraAbility source) {
        CameraAbility result = null;
        if (source != null) {
            result = new CameraAbility();
            result.setAppId(source.getAppId());
            result.setDeviceId(source.getDeviceId());
            result.setDeviceName(source.getDeviceName());
            result.setDeviceStatus(source.getDeviceStatus());
            result.setQualityVideo(source.getHdVideo());
            result.setSupportHDVideo(source.supportHDVideo());
            result.setSupportPtz(source.supportPtz());
            result.setSupportSdcardPlayback(source.supportSdcardPlayback());
            result.setSupportDuplexAudioTalk(source.supportDuplexAudioTalk());
        }
        return result;
    }
}
